﻿//===================================================================================
// Copyright (c) Ryan Garrett.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===================================================================================
using System;

namespace Caffeine.Core
{
    /// <summary>
    /// Implementers allow one property to sync to another property
    /// </summary>
    /// <typeparam name="T">Type of property to sync to</typeparam>
    public interface IPropertySync<T>
    {
        /// <summary>
        /// Gets the owning property of this sync object
        /// </summary>
        ModelScalarPropertyBase ParentProperty
        {
            get;
        }

        /// <summary>
        /// Gets the property that will be synced to if a strong reference to the property is held
        /// </summary>
        ModelProperty<T> SyncedToProperty
        {
            get;
        }

        /// <summary>
        /// Gets the property that will be synced to if a weak reference to the property is held
        /// </summary>
        WeakReference SyncedToPropertyReference
        {
            get;
        }

        /// <summary>
        /// Called when a value is to be synced from one property to another.
        /// </summary>
        /// <param name="value">Signal a value is ready to be synced</param>
        void SignalValueChange(T value);
    }
}
